package com.lingchou.cloud.process.api.controller;

import com.lingchou.cloud.process.api.dto.result.HistoricProcessInstanceDTO;
import com.lingchou.cloud.process.api.dto.result.HistoricTaskInstanceDTO;
import com.lc.common.bean.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * 流程历史查询API
 *
 * @author lc
 */
@RequestMapping(value = "process/v1")
@Api(value = "ProcessHistoryApi", tags = "流程历史查询API")
public interface ProcessHistoryApi {


    /**
     * 查询历史参与过的任务列表
     *
     * @param userId      参与人ID
     * @param businessKey 参与人ID
     * @return
     */
    @ApiOperation(value = "查询历史参与任务列表", notes = "查询某人历史参与完成任务列表,作为审批人或者作为归属人")
    @GetMapping("historicTaskListByInvoker")
    Result<List<HistoricTaskInstanceDTO>> historicTaskListByInvoker(@ApiParam(name = "userId", value = "参与人ID") @RequestParam(required = false) String userId,
                                                                    @ApiParam(name = "businessKey", value = "业务KEY") @RequestParam(required = false) String businessKey);

    /**
     * 查询历史参与过的任务列表
     *
     * @param userId      参与人ID
     * @param businessKey 业务KEy
     * @param key         任务Key
     * @return
     */
    @ApiOperation(value = "查询历史参与任务列表", notes = "查询某人历史参与完成任务列表,作为审批人或者作为归属人")
    @GetMapping("historicTaskListByInvokerAndKeyLike")
    Result<List<HistoricTaskInstanceDTO>> historicTaskListByInvokerAndKeyLike(@ApiParam(name = "userId", value = "参与人ID") @RequestParam(required = false) String userId,
                                                                              @ApiParam(name = "businessKey", value = "业务KEY") @RequestParam(required = false) String businessKey,
                                                                              @ApiParam(name = "key", value = "任务key") @RequestParam(required = false) String key);

    /**
     * 查询代理过的任务列表 可指定归属人
     *
     * @param assignee    执行人ID
     * @param owner       归属人ID
     * @param businessKey 业务KEY
     * @return
     */
    @ApiOperation(value = "查询代理过的任务列表", notes = "查询代理过的任务列表,作为审批人或者作为归属人")
    @GetMapping("historicTaskListByInvokerForUser")
    Result<List<HistoricTaskInstanceDTO>> historicTaskListByInvokerForUser(@ApiParam(name = "assignee", value = "执行人ID") @RequestParam String assignee,
                                                                           @ApiParam(name = "owner", value = "归属人ID") @RequestParam(required = false) String owner,
                                                                           @ApiParam(name = "businessKey", value = "业务KEY") @RequestParam(required = false) String businessKey);

    /**
     * 查询代理过的任务列表 可指定归属人
     *
     * @param assignee    执行人ID
     * @param owner       归属人ID
     * @param businessKey 业务KEY
     * @param key         任务Key
     * @return
     */
    @ApiOperation(value = "查询代理过的任务列表", notes = "查询代理过的任务列表,作为审批人或者作为归属人")
    @GetMapping("historicTaskListByInvokerForUserAndKeyLike")
    Result<List<HistoricTaskInstanceDTO>> historicTaskListByInvokerForUser(@ApiParam(name = "assignee", value = "执行人ID") @RequestParam String assignee,
                                                                           @ApiParam(name = "owner", value = "归属人ID") @RequestParam(required = false) String owner,
                                                                           @ApiParam(name = "businessKey", value = "业务KEY") @RequestParam(required = false) String businessKey,
                                                                           @ApiParam(name = "key", value = "任务key") @RequestParam(required = false) String key);


    /**
     * 查询某人参与过的流程
     *
     * @param userId      用户
     * @param businessKey 业务key
     * @return 流程列表
     */
    @ApiOperation(value = "查询历史参与流程列表", notes = "查询某人历史参与完成流程列表，可分页")
    @GetMapping("historicProcessListByInvoker")
    Result<List<HistoricProcessInstanceDTO>> historicProcessListByInvoker(@ApiParam(name = "userId", value = "参与人ID") @RequestParam(required = false) String userId,
                                                                          @ApiParam(name = "businessKey", value = "业务Key") @RequestParam(required = false) String businessKey);

    @ApiOperation(value = "查询历史发起流程列表", notes = "查询某人历史发起的完成流程列表，可分页")
    @GetMapping("historicProcessListByStarter")
    Result<List<HistoricProcessInstanceDTO>> historicProcessListByStarter(@ApiParam(name = "userId", value = "发起人ID") @RequestParam(required = false) String userId,
                                                                          @ApiParam(name = "startNum", value = "开始数") @RequestParam(required = false) Integer startNum,
                                                                          @ApiParam(name = "rows", value = "读取数") @RequestParam(required = false) Integer rows);


    @ApiOperation(value = "查询某实例的历史任务", notes = "查询某实例的所有完成的历史任务，实例不存在将返回error")
    @GetMapping("historicTasksForProcessInstance")
    Result<List<HistoricTaskInstanceDTO>> historicTasksForProcessInstance(@ApiParam(name = "processInstanceId", value = "流程实例ID") @RequestParam(required = false) String processInstanceId);
}
